package com.tony.blog.server.controller;

import com.tony.blog.model.entity.SysUserEntity;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: AbstractController
 * @Auther: 皮蛋布丁
 * @Date: 2021/07/11/14:13
 * @Description: 日志controller
 */
@Controller
public abstract class AbstractController {
    //日志
    protected Logger log = LoggerFactory.getLogger(getClass());

    /**
    * @Description: getUser 获取当前登录用户的详情
    * @Param: []
    * @return: com.tony.pmp.model.entity.SysUserEntity
    * @Author: 皮蛋布丁
    * @Date: 2021/7/13 20:58
    */
    protected SysUserEntity getUser(){
        SysUserEntity user= (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
        return user;
    }

    protected Long getUserId(){
        return getUser().getUserId();
    }

    protected String getUserName(){
        return getUser().getUsername();
    }

    protected Long getDeptId(){
        return getUser().getDeptId();
    }
}
